package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("mobile/validateCode")
public class ValidateCodeController {

    @DubboReference
    private SmsService smsService;

    /**
     * @Author: 15041
     * @Date: 17:07 2021/1/12
     * @Parms: [type, telephone]
     * @ReturnType: com.itheima.health.entity.Result
     *Description: 发送验证码
     * 接收前端传递过来的 type：验证码类型  telephone：手机号 调用方法得到验证码
    */
    @PostMapping("send")
    public Result send(String type,String telephone){
        log.info("验证码-发送验证码请求参数：type：{}，telephone：{}",type,telephone);
        smsService.sendValidateCode(type,telephone);
        return new Result(true, MessageConst.SEND_VALIDATECODE_SUCCESS);
    }


}
